#include "main.h"


//void Timer_Init(void)
//{
//    /* ----------------------------------------------------------------------------
//    TIMER1 Configuration: 
//    TIMER1CLK = SystemCoreClock/540 = 200KHz.
//    TIMER1 configuration is timing mode, and the timing is 0.2s(4000/200000 = 0.02s).
//    CH0 update rate = TIMER1 counter clock/CH0CV = 200000/4000 = 50Hz.
//    ---------------------------------------------------------------------------- */
//    timer_oc_parameter_struct timer_ocinitpara;
//    timer_parameter_struct timer_initpara;

//    timer_deinit(TIMER1);
//    /* initialize TIMER init parameter struct */
//    timer_struct_para_init(&timer_initpara);
//    /* TIMER1 configuration */
//    timer_initpara.prescaler         = 539;
//    timer_initpara.alignedmode       = TIMER_COUNTER_EDGE;
//    timer_initpara.counterdirection  = TIMER_COUNTER_UP;
//    timer_initpara.period            = 4000;
//    timer_initpara.clockdivision     = TIMER_CKDIV_DIV1;
//    timer_init(TIMER1, &timer_initpara);

//    /* initialize TIMER channel output parameter struct */
//    timer_channel_output_struct_para_init(&timer_ocinitpara);
//    /* CH0,CH1 and CH2 configuration in OC timing mode */
//    timer_ocinitpara.outputstate  = TIMER_CCX_ENABLE;
//    timer_ocinitpara.ocpolarity   = TIMER_OC_POLARITY_HIGH;
//    timer_ocinitpara.ocidlestate  = TIMER_OC_IDLE_STATE_LOW;
//    timer_channel_output_config(TIMER1, TIMER_CH_0, &timer_ocinitpara);

//    /* CH0 configuration in OC timing mode */
//    timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_0, 2000);
//    timer_channel_output_mode_config(TIMER1, TIMER_CH_0, TIMER_OC_MODE_TIMING);
//    timer_channel_output_shadow_config(TIMER1, TIMER_CH_0, TIMER_OC_SHADOW_DISABLE);

//    timer_interrupt_enable(TIMER1, TIMER_INT_CH0);
//    timer_enable(TIMER1);
//    
//	nvic_irq_enable(TIMER1_IRQn, 1, 1);
//}

//unsigned char rtc_time_count = 0;
//unsigned char rtc_time_flag = 0;
//extern void Key_scan(void);
//void TIMER1_IRQHandler(void)
//{
//    if(SET == timer_interrupt_flag_get(TIMER1, TIMER_INT_CH0)){
//        timer_interrupt_flag_clear(TIMER1, TIMER_INT_CH0);
//        delay_decrement();
//        Key_scan();
//        
//        if(rtc_time_flag == 0)
//        {
//            rtc_time_count++;
//        }
//        if(rtc_time_count == 50)
//        {
//            rtc_time_count = 0;
//            rtc_time_flag = 1;
//        }
//    }
//}




